<%--
  Created by IntelliJ IDEA.
  User: 17628
  Date: 2021/4/22
  Time: 19:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <jsp:include page="header.jsp"/>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>用户-登录</title>
        <link rel="stylesheet" type="text/css" href="css/common.css">
        <link rel="stylesheet" type="text/css" href="css/login.css">
        <script>

            $(function () {
                //1.给登录按钮绑定单击事件
                $("#btn_sub").click(function () {
                    //2.发送ajax请求，提交表单数据
                    $.post("user/login",$("#loginForm").serialize(),function (data) {
                        //data : {flag:false,errorMsg:''}
                        if(data.flag){
                            //登录成功
                            location.href="index.jsp";
                        }else{
                            //登录失败
                            $("#errorMsg").html(data.errorMsg);
                        }
                    });
                });
            });
            //3.处理响应结果
        </script>
    </head>
    <body>
        </div>
            <!-- 头部 end -->
            <section id="login_wrap">
                <div class="fullscreen-bg" style="background: url(images/login_bg.png);height: 532px;">

                </div>
                <div class="login-box">
                    <div class="title">
                        <img src="images/login_logo.png" alt="">
                        <span>欢迎登录旅游账户</span>
                    </div>
                    <div class="login_inner">

                        <!--登录错误提示消息-->
                        <div id="errorMsg" class="alert alert-danger" ></div>
                        <form id="loginForm" action="" method="post" accept-charset="utf-8">
                            <input type="hidden" name="action" value="login"/>
                            <input name="username" type="text" placeholder="请输入账号" autocomplete="off">
                            <input name="password" type="password" placeholder="请输入密码" autocomplete="off">
                            <div class="verify">
                                <input name="check" type="text" placeholder="请输入验证码" autocomplete="off">
                                <span><img src="checkCode" alt="" onclick="changeCheckCode(this)"></span>
                                <script type="text/javascript">
                                    //图片点击事件
                                    function changeCheckCode(img) {
                                        img.src="checkCode?"+new Date().getTime();
                                    }
                                </script>
                            </div>
                            <div class="submit_btn">
                                <button type="button"  id="btn_sub">登录</button>
                                <div class="auto_login">
                                    <input type="checkbox" name="" class="checkbox">
                                    <span>自动登录</span>
                                </div>
                            </div>
                        </form>
                        <div class="reg">没有账户？<a href="javascript:;">立即注册</a></div>
                    </div>
                </div>
            </section>
        </div>
    </body>
</html>
